home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tex / macros / contrib / exam.cls < prev    next >
Encoding:
Text File  |  1995-03-15  |  14.2 KB  |  413 lines

  1. %% 
  2. %% This is file `exam.cls', generated 
  3. %% on <1995/3/4> with the docstrip utility (2.2i).
  4. %% 
  5. %% The original source files were:
  6. %% 
  7. %% exam.dtx  (with options: `package')
  8. %% 
  9. %% Copyright (C) 1994 by LaTeX3 project. All rights reserved. 
  10. %% For additional copyright information see further down in this file. 
  11. %% 
  12. %% This file is part of the LaTeX2e system (PRELIMINARY TEST RELEASE). 
  13. %% ------------------------------------------------------------------- 
  14. %% 
  15. %% This system is distributed in the hope that it will be useful, 
  16. %% but WITHOUT ANY WARRANTY; without even the implied warranty of 
  17. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  18. %% 
  19. %% 
  20. %% IMPORTANT NOTICE: 
  21. %% 
  22. %% For error reports in case of UNCHANGED versions see readme files. 
  23. %% 
  24. %% Please do not request updates from us directly. Distribution is 
  25. %% done through Mail-Servers and TeX organizations. 
  26. %% 
  27. %% You are not allowed to change this file. 
  28. %% 
  29. %% You are allowed to distribute this file under the condition that 
  30. %% it is distributed together with all files mentioned in 00readme.l2e. 
  31. %% 
  32. %% If you receive only some of these files from someone, complain! 
  33. %% 
  34. %% You are NOT ALLOWED to distribute this file alone. You are NOT 
  35. %% ALLOWED to take money for the distribution or use of either this 
  36. %% file or a changed version, except for a nominal charge for copying 
  37. %% etc. 
  38. \def\fileversion{3.13}
  39. \def\filedate{1994/11/10}
  40. %% File: exam.dtx Copyright (C) 1993-1994 Hans van der Meer
  41. %% \CharacterTable
  42. %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  43. %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  44. %%   Digits        \0\1\2\3\4\5\6\7\8\9
  45. %%   Exclamation   \!     Double quote  \"     Hash (number) \#
  46. %%   Dollar        \$     Percent       \%     Ampersand     \&
  47. %%   Acute accent  \'     Left paren    \(     Right paren   \)
  48. %%   Asterisk      \*     Plus          \+     Comma         \,
  49. %%   Minus         \-     Point         \.     Solidus       \/
  50. %%   Colon         \:     Semicolon     \;     Less than     \<
  51. %%   Equals        \=     Greater than  \>     Question mark \?
  52. %%   Commercial at \@     Left bracket  \[     Backslash     \\
  53. %%   Right bracket \]     Circumflex    \^     Underscore    \_
  54. %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  55. %%   Right brace   \}     Tilde         \~}
  56. \NeedsTeXFormat{LaTeX2e}[1993/12/01]
  57. \ProvidesClass{exam}[\filedate\space vs\fileversion\space Exam package]
  58. \newcommand\examerror[2]{\ClassError{exam}{!!!! #1}{#2}}
  59. \newcommand\examwarning[1]{\ClassWarning{exam}{!!!! #1}}
  60. \DeclareOption{help}{%
  61.     \ClassWarningNoLine{exam}{available options are:\MessageBreak
  62.     answers:\space show questions with answers;\MessageBreak
  63.     series:\space\space typeset a catalogue of problems}}
  64. \newif\ifanswers
  65. \DeclareOption{answers}{\answerstrue}
  66. \AtBeginDocument{\ifanswers\ClassWarningNoLine{exam}{Repeat typesetting for %
  67.     good table of contents}\fi}
  68. \newif\ifseries
  69. \DeclareOption{series}{\seriestrue\answerstrue}
  70. \providecommand\parentclass{article}
  71. \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\parentclass}}
  72. \PassOptionsToClass{titlepage}{\parentclass}
  73. \ProcessOptions
  74. \LoadClass{\parentclass}
  75. \newcounter{examnum}
  76. \newenvironment{exam}[2][0]{%
  77.   \stepcounter{examnum}%
  78.   \@ifemptyarg{#2}{}{\date{#2}}%
  79.   \ifseries\else\ifanswers
  80.     \addcontentsline{toc}{section}{\Exam~\theexamnum~---~\@date}%
  81.   \fi\fi
  82.     \ifanswers
  83.         \pagenumbering{roman}%
  84.         \maketitle\tableofcontents\cleardoublepage
  85.     \fi
  86.     \pagenumbering{arabic}%
  87.     \ifseries\SRset{0}\else
  88.         \SRset{#1}%
  89.         \addcontentsline{toc}{subsection}{Start value random generator = #1}%
  90.     \fi
  91.   \setcounter{page}{1}}%
  92.   {\ifseries\else
  93.     \typeout{Total value scores = \thetotalscore}%
  94.     \ifanswers
  95.       \addcontentsline{toc}{subsection}{Total value scores = \thetotalscore}%
  96.     \else\maketitle\fi\fi}
  97. \newcounter{problemnum}[examnum]
  98. \newtoks\problemid
  99. \newcommand\question[3][]{%
  100.   \@ifemptyarg{#1}{}{\renewcommand\parameter{#1}}%
  101.   \ifseries
  102.     \uppercase{\def\@namesection{#2}}%
  103.     \ifx\namesection\@namesection
  104.     \else
  105.       \newpage
  106.       \global\let\namesection=\@namesection
  107.       \addcontentsline{toc}{subsection}{\namesection}%
  108.       \setcounter{problemnum}{0}%
  109.     \fi
  110.   \fi
  111.   \problemid={\uppercase{#3}}%
  112.   \ifseries
  113.     \noindent\underbar{\emph{File\,:}~\texttt{\the\problemid}}\par
  114.     \nopagebreak\medskip\nopagebreak
  115.   \fi
  116.   \stepcounter{problemnum}%
  117.   \IfFileExists{\mainfolder#2:#3}{\@@input \mainfolder#2:#3}%
  118.     {\examwarning{File \mainfolder#2:#3 not found}}%
  119.   \ifseries\else
  120.     \addtocounter{totalscore}{\value{scorecounter}}%
  121.     \typeout{\Problem\space\theproblemnum: score=\thescorecounter}%
  122.   \fi
  123.   \ifanswers
  124.     \addcontentsline{toc}{subsubsection}%
  125.       {\hbox to1cm{\theproblemnum:\hss}%
  126.       \hbox{#3~~[score = \thescorecounter]}}%
  127.   \fi}
  128. \newcommand\namesection{}
  129. \newcommand\reset@parameter{\gdef\parameter{}}
  130. \reset@parameter
  131. \newcommand\parameterproblem[2][1 ]{%
  132.   \ifx\parameter\@empty
  133.     \ifseries\else\examwarning{\string\parameter\space undefined,
  134.     value `#1' taken}\fi
  135.     \renewcommand\parameter{#1}%
  136.   \fi
  137.   \remark[Parameter \Problem]{#2}}
  138.  
  139. \newtoks\everyproblem
  140. \newenvironment{problem}[1][]{%
  141.   \@tagsforbidfalse\compact\the\everyproblem#1\@tagsforbidtrue
  142.   \@boxing\bgroup\noindent\problemstart\ignorespaces}%
  143.   {\par\nopagebreak\smallskip\nopagebreak
  144.   \hbox to\linewidth{\hrulefill
  145.     \ifseries\emph{\footnotesize\thinspace\the\@problemdate}\fi}%
  146.   \egroup\par\bigskip\reset@problemdate\reset@parameter}
  147. \newcommand\compact{\@chktag\compact\def\@boxing{\noindent\vbox}\fi}
  148. \newcommand\split{\@chktag\split\def\@boxing{\@empty}\fi}
  149. \newif\if@tagsforbid \@tagsforbidtrue
  150. \providecommand\@chktag[1]{%
  151.   \if@tagsforbid\@warning{tag \string#1\space ignored here}\else}
  152. \newcommand\@problemstart{%
  153.   \textbo{\Problem\,\ifnum\value{problemnum}<10 \phantom{0}\fi
  154.   \theproblemnum}.\enskip}
  155. \newcommand\problemstart{%
  156.   \hangafter-2\settowidth\hangindent{\@problemstart}%
  157.   \noindent\llap{\@problemstart}}
  158. \newtoks\@problemdate
  159. \newcommand\problemdate[1]{\global\@problemdate={#1}\ignorespaces}
  160. \newcommand\reset@problemdate{\global\@problemdate={}}
  161. \reset@problemdate
  162. \newcounter{totalscore}[examnum]
  163. \newcounter{scorecounter}[problemnum]
  164. \newcommand\scoreboxsize{6mm}
  165. \newcommand\scorebox[1]{%
  166.   \fbox{\vbox to\scoreboxsize{\vss\hbox to\scoreboxsize{\hss#1\hss}\vss}}}
  167. \newcommand\score[1]{%
  168.   \addtocounter{scorecounter}{#1}%
  169.   \rightnote[-\normalbaselineskip]{\scorebox{\ifanswers#1\fi}}%
  170.   \ignorespaces}
  171. \providecommand\leftnote[1][\z@skip]{\@rlnote l{#1}}
  172. \providecommand\rightnote[1][\z@skip]{\@rlnote r{#1}}
  173. \providecommand\@rlnote[3]{%
  174.   \noindent\vadjust{\vbox to\z@{%
  175.     \vskip#2\leftskip\z@skip\rightskip\z@skip\noindent
  176.     \if#1l\llap{#3\hskip\marginparsep}%
  177.     \else\hfill\rlap{\hskip\marginparsep#3}\fi
  178.     \vss\vskip\z@skip}}}
  179. \newcommand\remark[2][]{%
  180.     \ifseries
  181.         \begin{center}%
  182.         \fbox{\parbox{.9\linewidth}{%
  183.             \sloppy\hangafter\@ne
  184.             \setbox\z@=\hbox{\emph{#1}\@ifemptyarg{#1}{}{:~}}%
  185.             \hangindent=\wd\z@
  186.             \strut\box\z@ #2}}%
  187.         \end{center}\nopagebreak
  188.         \addvspace{5mm}\nopagebreak
  189.     \fi}
  190. \newcommand\longwhite{25mm}
  191. \newcommand\shortwhite{8mm}
  192. \newcommand\answerstart{\emph{\Answer}:\enspace}
  193.  
  194. \newcommand\answer[2][]{\altanswer[#1]{}{#2}}
  195. \newcommand\altanswer[3][]{%
  196.   \@ifemptyarg{#1}%
  197.     {\mbox{\ifanswers#3\fi}}%
  198.     {\makebox[#1]{\ifanswers#3\else#2\fi}}%
  199.   }
  200. \newcommand\shortanswer[2][.75\linewidth]{\par
  201.   \ifanswers
  202.     \addvspace{\smallskipamount}%
  203.     \noindent\answerstart\parbox[t]{#1}{\noindent #2}%
  204.   \else
  205.     \addvspace{\shortwhite}%
  206.     \noindent\answerstart\makebox[#1]{\dotfill}\fi
  207.   \par}
  208. \newenvironment{longanswer}[1][\longwhite]{
  209.   \par\addvspace{\medskipamount}%
  210.   \noindent\answerstart\par\nopagebreak
  211.   \ifanswers\noindent\else
  212.     \hrule\@height#1\@width\z@\par
  213.     \setbox\z@\vbox\bgroup
  214.        \leavevmode
  215.    \fi}
  216.       {\ifanswers\else\egroup\setbox\z@\hbox{}\fi}
  217. \newcount\loadcounter
  218. \newcommand\resetloadcounter{\global\loadcounter\z@}
  219. \newcommand\incloadcounter{\global\advance\loadcounter\@ne}
  220. \newcommand\decloadcounter{\global\advance\loadcounter\m@ne}
  221. \newcommand\@listk{%
  222.   \settowidth{\leftmargin}{\@problemstart}%
  223.   \topsep\medskipamount
  224.   \partopsep\z@
  225.   \itemsep\smallskipamount
  226.   \parsep\z@}
  227. \newenvironment{choice}[1][]{%
  228.   \@tagsforbidfalse\ifseries\ordered\else\random\fi#1\@tagsforbidtrue
  229.   \resetloadcounter
  230.   \ifnum\@itemdepth>3 \@toodeep \else
  231.   \advance\@itemdepth\@ne
  232.   \expandafter\let
  233.     \csname @list\romannumeral\the\@itemdepth\endcsname=\@listk
  234.   \list{\badmark}{\def\makelabel##1{\hss\llap{##1}}}%
  235.   \fi}%
  236.   {\@dumpitems\endlist}
  237. \newcommand\random{\@chktag\random
  238.     \def\@loaditem{\loaditem}%
  239.     \def\@dumpitems{\shuffle\dumpitems}%
  240.   \fi}
  241. \newcommand\ordered{\@chktag\ordered
  242.     \def\@loaditem{}%
  243.     \def\@dumpitems{}%
  244.   \fi}
  245. \providecommand\square{\bigcirc}
  246. \providecommand\checksquare{\surd}
  247. \newcommand\badmark{$\square$}
  248. \newcommand\goodmark{\ifanswers$\checksquare$\else\badmark\fi}
  249. \newcommand\baditem[1]{\@loaditem{\item[\badmark]#1}}
  250. \newcommand\gooditem[1]{\@loaditem{\item[\goodmark]#1}}
  251. \newtoks\@itemA
  252. \newtoks\@itemB
  253. \newtoks\@itemC
  254. \newtoks\@itemD
  255. \newtoks\@itemE
  256. \newcommand\@itemstore{5}
  257. \newcommand\loaditem[1]{%
  258.   \ifcase\loadcounter
  259.     \@itemA={#1}%
  260.     \or\@itemB={#1}%
  261.     \or\@itemC={#1}%
  262.     \or\@itemD={#1}%
  263.     \or\@itemE={#1}%
  264.   \fi
  265.   \ifnum\loadcounter<\@itemstore \incloadcounter
  266.   \else\examwarning{\string\loaditem\space ignored, too many}\fi}
  267. \newcommand\dumpitemno[1]{%
  268.   \ifnum#1>\loadcounter
  269.     \examwarning{\string\dumpitemno[#1] ignored, out range}%
  270.   \else\ifcase#1\relax
  271.     \or\the\@itemA
  272.     \or\the\@itemB
  273.     \or\the\@itemC
  274.     \or\the\@itemD
  275.     \or\the\@itemE
  276.   \fi\fi}
  277. \newcommand\dumpitem{\dumpitemno{\loadcounter}\decloadcounter}
  278. \newcommand\dumpitems{\@whilenum\loadcounter>\z@\do{\dumpitem}}
  279. \newcommand\shuffle{%
  280.   \ifcase\loadcounter
  281.     \or
  282.     \or\shuffle@ii
  283.     \or\shuffle@\@itemA\@itemC \shuffle@ii \shuffle@\@itemB\@itemC
  284.     \or\shuffle@iv
  285.     \or\shuffle@\@itemD\@itemE \shuffle@iv \shuffle@\@itemD\@itemE
  286.     \fi
  287.   }
  288. \newtoks\@item@
  289. \newcommand\shuffle@[2]{\SRtest{}{\@item@=#1 #1=#2 #2=\@item@}}
  290. \newcommand\shuffle@ii{\shuffle@\@itemA\@itemB}
  291. \newcommand\shuffle@iv{%
  292.   \SRtest{\shuffle@\@itemA\@itemB}{\shuffle@\@itemC\@itemD}%
  293.   \SRtest{\shuffle@\@itemA\@itemC}{\shuffle@\@itemB\@itemD}}
  294. \ifx\@SR\undefined\newcount\@SR\fi
  295. \providecommand\@SRconst{2097152}
  296. \providecommand\SRset[1]{\global\@SR#1 \ignorespaces}
  297. \providecommand\@SRadvance{%
  298.   \begingroup
  299.   \ifnum\@SR<\@SRconst\relax\count@\z@\else\count@\@ne\fi
  300.   \ifodd\@SR\advance\count@\@ne\fi
  301.   \global\divide\@SR\tw@
  302.   \ifodd\count@\global\advance\@SR\@SRconst\relax\fi
  303.   \endgroup}
  304. \providecommand\SRbit{\@SRadvance\ifodd\@SR1\else0\fi}
  305. \providecommand\SRtest[2]{\@SRadvance\ifodd\@SR#2\else#1\fi\ignorespaces}
  306. \providecommand\SRvalue{\number\@SR }
  307. \SRset{0}
  308. \newcommand\thehead{%
  309.   \slshape\@title\enspace\upshape:\enspace
  310.   \ifseries\namesection\else\@date\fi}
  311. \newcommand\ps@examheadings{%
  312.   \let\@oddfoot\@empty
  313.   \let\@evenfoot\@empty
  314.   \renewcommand\@oddhead{%
  315.     \vbox{%
  316.     \hbox to\textwidth{\headerfont\thehead\hfil\upshape\thepage}%
  317.     \vskip1.5\p@
  318.     \hrule\@height.5\p@\@width\textwidth
  319.     }}%
  320.   \let\@evenhead\@oddhead}
  321. \newcommand\target[1]{\gdef\@target{#1}}\def\@target{}
  322. \newcommand\Copyright{\mbox{}}
  323. \renewcommand\maketitle{%
  324. \if@titlepage\begin{titlepage}
  325.   \begin{center}\titlefont
  326.     \vspace*{1cm}%
  327.     \mbox{}\rule{2cm}{0.4pt}\mbox{}\par
  328.     \addvspace{1cm}%
  329.     \begin{Large}
  330.       \textbf{\ifseries\Collection\else\Exam\fi}\\[10mm]
  331.     \end{Large}
  332.     \begin{large}
  333.       \@title\\[5mm]
  334.       \ifseries\@author\else\@target\fi\\[5mm]
  335.       \@date\\[10mm]
  336.     \end{large}
  337.     \mbox{}\rule{2cm}{0.4pt}\mbox{}\par
  338.     \addvspace{2cm}%
  339.   \ifseries
  340.     \vfill\vfill
  341.     \begin{flushleft}%
  342.       \Copyright
  343.     \end{flushleft}%
  344.   \else\ifanswers
  345.       \begin{huge}\Answers\end{huge}\par
  346.     \else
  347.       \begin{minipage}{.75\textwidth}%
  348.       \raggedright\parindent\medskipamount
  349.         Naam:\enspace\dotfill\strut\par
  350.         Adres:\enspace\dotfill\strut\par
  351.         Plaats:\enspace\dotfill\strut\par
  352.         Collegekaart:\enspace\dotfill\strut\par
  353.         \vspace{1cm}%
  354.         \begin{itemize}%
  355.         \item Zonder geldige collegekaart wordt geen
  356.           tentamenbriefje uitgereikt.
  357.         \item U wordt met nadruk verzocht om een
  358.           \emph{leesbaar} schrift; wat niet leesbaar
  359.           is, wordt fout gerekend.
  360.         \item Denk erom losse vellen tentamenpapier
  361.           van Uw naam en collegekaartnummer te voorzien;
  362.           gebruik blokletters voor de leesbaarheid.
  363.         \item Dit tentamen telt \theproblemnum\ opgaven
  364.         \end{itemize}%
  365.       \end{minipage}\\[10mm]
  366.       \GoodLuck\par
  367.     \fi
  368.   \fi
  369.   \end{center}%
  370. \end{titlepage}\fi}
  371. \newcommand\onlanguage[4]{% {language}{current}{existing}{not existing}
  372.   \expandafter\ifx\csname l@#1\endcsname\relax
  373.   #4\else\ifnum\csname l@#1\endcsname=\language #2\else#3\fi\fi}
  374. \newcommand\englishExamNames{%
  375.   \newcommand\Answers{ANSWERS}%
  376.   \newcommand\Answer{Answer}%
  377.   \newcommand\GoodLuck{Good luck!}%
  378.   \newcommand\Exam{EXAM}%
  379.   \newcommand\Collection{COLLECTION OF EXAMS}%
  380.   \newcommand\Problem{Problem}%
  381.   }
  382. \AtBeginDocument{\onlanguage{english}{\englishExamNames}{}{}}
  383. \AtBeginDocument{\onlanguage{american}{\englishExamNames}{}{}}
  384. \newcommand\dutchExamNames{%
  385.   \newcommand\Answers{ANTWOORDEN}%
  386.   \newcommand\Answer{Antwoord}%
  387.   \newcommand\GoodLuck{Veel succes!}%
  388.   \newcommand\Exam{TENTAMEN}%
  389.   \newcommand\Collection{TENTAMENBUNDEL}%
  390.   \newcommand\Problem{Opgave}%
  391.   }
  392. \AtBeginDocument{\onlanguage{dutch}{\dutchExamNames}{}{}}
  393. \newcommand\fullanswer{Geef de volledige afleiding; %
  394.   slechts het antwoord vermelden wordt \emph{niet} goed gerekend.}
  395. \providecommand\textbo{\textbf}
  396. \providecommand\@ifemptyarg[1]{% {absence}{presence}
  397.   \ifx\@empty#1\@empty
  398.   \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
  399. \newcommand\headerfont{\rmfamily\small}
  400. \newcommand\bodyfont{\sffamily}
  401. \newcommand\titlefont{\rmfamily\upshape}
  402. \bodyfont
  403. \newcommand\Mainfolder[1]{\def\mainfolder{#1}}
  404. \newcommand\Commonfolder[1]{\def\commonfolder{#1}}
  405. \newcommand\Figuresfolder[1]{\def\figuresfolder{#1}}
  406. \Mainfolder{\@currdir}
  407. \Commonfolder{\@currdir}
  408. \Figuresfolder{\@currdir}
  409. \InputIfFileExists{exam.cfg}{}{}
  410. \endinput
  411. %% 
  412. %% End of file `exam.cls'.
  413.